<?php
/**
* @author: Pham Van Diep
* @date:   18/2/2014
*/

/**
* Not login
* Not permission
*
* Note: only root, administrator, leader with permission admin module
*/
if( !isset($AppUI) || 	
    !isset($_SESSION['club'])
) {
	redirect(HOST_BACKEND);
}

$this->load->model('club_model', 'club');	
$intPage    = CI_Function::stripTag(trim($this->input->get('page', 1)));
$strStart   = CI_Function::stripTag(trim($this->input->get('startdate', null)));
$strEnd     = CI_Function::stripTag(trim($this->input->get('enddate', null)));
$strStatus  = CI_Function::stripTag(trim($this->input->get('status',-1)));
$intOption  = CI_Function::stripTag(trim($this->input->get('option',0)));
$strKeyword  = CI_Function::stripTag(trim($this->input->get('keyword',null)));
$intLimit   = 20;
$intOffset  = ($intPage-1)*$intLimit;
$arrResult	= $this->club->getAll($AppUI->id,
								$strStatus,
								$intOption,
								$strKeyword,
								CI_Function::convertStrToDate($strStart),
								CI_Function::convertStrToDate($strEnd),
								$intOffset,
								$intLimit);
if($arrResult == null) $_SESSION['CLUB_ERROR']=$arrError['problem_save_db_error'];
else if(isset($_SESSION['CLUB_ERROR'])){
	unset($_SESSION['CLUB_ERROR']);
	$intTotal   = count($arrResult);
	$this->smarty->assign('arrResult',  $arrResult);
}
$this->smarty->assign('intTotal',   $intTotal);
$this->smarty->assign('intOffset',  $intOffset);
$this->smarty->assign('intLimit',   $intLimit);
//$this->smarty->assign('arrStatus',  $arrStatus);
$this->smarty->assign('type',    $AppUI->type);
$this->smarty->display('club/index.tpl');